package com.xayy.mgt.controller;

import cn.kawins.base.result.CheckResult;
import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import com.xayy.mgt.model.dto.GenerateTheoryDataDto;
import com.xayy.mgt.model.vo.ConfigFileVo;
import com.xayy.mgt.model.vo.SateRateAndCacheVo;
import com.xayy.mgt.model.xinwangmodel.AssessData;
import com.xayy.mgt.model.xinwangmodel.SateLinkData;
import com.xayy.mgt.service.GenerateTheoryDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 生成理论数据
 * @author plq
 */
@Api(tags = "生成理论数据")
@RestController
@RequestMapping(value = "/generateTheoryData1")
@Slf4j
public class GenerateTheoryDataController  extends BaseController<AssessData> {

    @Autowired
    private  GenerateTheoryDataService generateTheoryDataService;

    @PostMapping(value = "/uploadFile")
    @ApiOperation(value = "文件上传",httpMethod = "POST",response = String.class,notes = "生成理论数据-文件上传")
    public ResultBody uploadFile(@RequestBody GenerateTheoryDataDto dataDto) {
        CheckResult<Object> result = generateTheoryDataService.execute(dataDto);
        return ResultBody.success(result);
    }

    @GetMapping(value = "/getConfigFile")
    @ApiOperation(value = "查询配置文件",httpMethod = "GET",response = String.class,notes = "查询配置文件")
    public ResultBody getConfigFile() {
        CheckResult<Object> result = generateTheoryDataService.getConfigFile();
        return ResultBody.success(result);
    }

    @PostMapping(value = "/updateConfigFile")
    @ApiOperation(value = "修改配置文件",httpMethod = "POST",response = String.class,notes = "修改配置文件")
    public ResultBody updateConfigFile(@RequestBody List<ConfigFileVo> configFileVo) {
        CheckResult<Object> result = generateTheoryDataService.updateConfigFile(configFileVo);
        return ResultBody.success(result);
    }


    @GetMapping(value = "/getTheoryData")
    @ApiOperation(value = "获取理论的卫星数据和链路数据",httpMethod = "GET",response = SateLinkData.class,notes = "生成理论数据-获取理论的卫星数据和链路数据")
    public ResultBody getTheoryData(@ApiParam("region:=1 卫星vs卫星 ,= 2 卫星vs地面站 ,= 3 地面站vs卫星") @RequestParam("region") String region ,@RequestParam("nodeId") Long nodeId) {
        CheckResult<Object> result = generateTheoryDataService.getTheoryData(region,nodeId);
        return ResultBody.success(result);
    }

    @GetMapping(value = "/siteRateAndCache")
    @ApiOperation(value = "获取理论的卫星速率以及缓存",httpMethod = "GET",response = SateRateAndCacheVo.class,notes = "生成理论数据-获取理论的卫星速率以及缓存")
    public ResultBody siteRateAndCache(@RequestParam("nodeId") Long nodeId) {
        CheckResult<Object> result = generateTheoryDataService.siteRateAndCache(nodeId);
        return ResultBody.success(result);
    }


}
